package com.yzt.dynamicmodule.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.yzt.dynamicmodule.R;
import com.yzt.plugin_widget.RoundImageView;
import com.yzt.zhuju.network.entity.game.GameUserListBean;
import com.yzt.zhuju.widget.tuiview.TUIImageView;
import com.yzt.zhuju.widget.widget.ImageLoadManger;

/**
 * author : bob
 * date   : 2023/2/27
 * desc   : 动态的适配器
 */
public class ActivityGameInUserAdapter extends BaseQuickAdapter<GameUserListBean, BaseViewHolder> {

    public ActivityGameInUserAdapter() {
        super(R.layout.item_game_room_user);
    }

    @Override
    protected void convert(BaseViewHolder holder, GameUserListBean item) {
        RoundImageView imgHeader = holder.findView(R.id.img_header);
        TUIImageView imgGender = holder.findView(R.id.img_gender);

        if (item.getType() == 0) {
            ImageLoadManger.loadIv(getContext(), item.getAvatar(), imgHeader, R.mipmap.default_photo);
            imgGender.setSelected(item.getGender() == 0);
            holder.setVisible(R.id.img_header, true);
            holder.setVisible(R.id.img_gender, true);
            holder.setVisible(R.id.ll_user_more_container, false);
            holder.setVisible(R.id.tv_host, item.isEmcee());
        } else {
            holder.setVisible(R.id.tv_host, false);
            holder.setVisible(R.id.img_header, false);
            holder.setVisible(R.id.img_gender, false);
            holder.setVisible(R.id.ll_user_more_container, true);
            if (item.getType() == 1) {
                holder.setVisible(R.id.img_user_right, true);
                holder.setVisible(R.id.tv_user_list_num, false);
            } else {
                holder.setText(R.id.tv_user_list_num, item.getUserTotal());
                holder.setVisible(R.id.img_user_right, false);
                holder.setVisible(R.id.tv_user_list_num, true);
            }
        }
    }
}